<?php include("../../includes/includes.php"); ?>
<?php
connect($config);
$loggedInTeam = getLoggedInTeam();
$currentRound = getCurrentRound();

if ($loggedInTeam == null || $loggedInTeam->id == null) {
	header( 'Location: ../notAuthenticated.php' );
	die();
}
else if (getCurrentRoundStatus() == RoundStatusType::Lockout) {
	header( 'Location: ../homePage.php?submitTeamError=true' );
	die();
}

clearPositionsForRound($loggedInTeam->id, $currentRound);

$positions = Position::getAll();
$count = count($positions);
for ($i = 0; $i < $count; $i++) {
	$playerId = $_GET[$positions[$i]];
	if ($playerId != -1) {
		setPositionForRound($loggedInTeam->id, $playerId, $positions[$i], $currentRound);
	}
}

updateTeamSubmittedStatus($loggedInTeam->id);

mysql_close();

header( 'Location: ../home/homePage.php' );
?>